package com.dao.rxjava01.uis.activities;

import android.databinding.DataBindingUtil;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebSettings;
import android.widget.Toast;

import com.dao.green.cn.applibary.uis.BaseActivity;
import com.dao.rxjava01.R;
import com.dao.rxjava01.databinding.AcDemo02Binding;

/**
 * Created by Ant on 2017/7/10  10:12
 * <p>
 * <p>
 *
 * @version 1.0.0
 * @auther Ant
 */

public class Demo02 extends BaseActivity implements View.OnClickListener {
    private AcDemo02Binding binding;


    @Override
    public void bindLayout() {
        binding = DataBindingUtil.setContentView(this, R.layout.ac_demo02);
    }

    @Override
    public void initView() {
        WebSettings settings = binding.acDemo02WebView.getSettings();
        settings.setAllowFileAccess(true);
        settings.setAllowContentAccess(true);
        settings.setJavaScriptEnabled(true);
    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {
        binding.acObtStart.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.acObtStart:
                toUrl();
                break;
        }
    }

    private void toUrl() {
        String s = binding.acDemo02EdTxt.getText().toString();
        if (TextUtils.isEmpty(s)) {
            Toast.makeText(this, "url is empty",Toast.LENGTH_SHORT).show();
        } else {
            binding.acDemo02WebView.loadUrl(s);
        }
    }
}
